package dao.impl;

import dao.DeptDao;
import pojo.Dept;
import utils.MyBatisUtil;

import java.util.List;

public class DeptDaoImpl implements DeptDao {
    @Override
    public List<Dept> findAll() {
     /*  //引入mybatis配置文件
        String resource = "mybatis-config.xml";
        SqlSession sqlSession=null;
        //加载配置文件
        try {
            InputStream resourceAsStream = Resources.getResourceAsStream(resource);
            //创建会话工厂
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
            //创建会话
           sqlSession = sqlSessionFactory.openSession();
            //执行查询
            List<Dept> depts =sqlSession.getMapper(DeptDao.class).findAll();
            return depts;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            sqlSession.close();
        }

    }
}*/

        return MyBatisUtil.getSession().getMapper(DeptDao.class).findAll();

    }
}